<template>
  <common-page
    ref="commonPage"
    :bg-path="bgPath"
    :web-path="webPath"
    :columns="columns"
    :search-items="searchItems"
    :form-items="formItems"
  />
</template>
<script>
export default {
  data: function() {
    return {
      // ===== ===== ===== ===== 全局属性 ===== ===== ===== =====
      // 后台接口路径
      bgPath: 'health/health/drug/drugrecord',
      // Web路径
      webPath: 'health/Health/Drug/DrugRecord',
      // ===== ===== ===== ===== 页面配置 ===== ===== ===== =====
      // 搜索内容
      searchItems: [
        {
          rowIndex: 1,
          items: [
            {
              code: "userCode",
              name: "用户编码",
              span: 6,
              type: "text",
              config: {
                edit: false
              }
            },
            {
              code: "userName",
              name: "用户名称",
              span: 6,
              type: "text",
              config: {
                edit: false
              }
            },
            {
              code: "drugCode",
              name: "药品编码",
              span: 6,
              type: "text",
              config: {
                edit: false
              }
            },
            {
              code: "drugName",
              name: "药品名称",
              span: 6,
              type: "text",
              config: {
                edit: false
              }
            },
            {
              code: "minRecordDate",
              name: "最早记录时间",
              span: 6,
              type: "date",
              config: {}
            },
            {
              code: "maxRecordDate",
              name: "最晚记录时间",
              span: 6,
              type: "date",
              config: {}
            },
            {
              code: "minRecordTime",
              name: "最早记录时间",
              span: 6,
              type: "date",
              config: {}
            },
            {
              code: "maxRecordTime",
              name: "最晚记录时间",
              span: 6,
              type: "date",
              config: {}
            }
          ]
        }
      ],
      // 列表内容
      columns: [
        {
          code: "userCode",
          name: "用户编码",
          span: 6,
          type: "text",
          config: {
            edit: false
          }
        },
        {
          code: "userName",
          name: "用户名称",
          span: 6,
          type: "text",
          config: {
            edit: false
          }
        },
        {
          code: "drugCode",
          name: "药品编码",
          span: 6,
          type: "text",
          config: {
            edit: false
          }
        },
        {
          code: "drugName",
          name: "药品名称",
          span: 6,
          type: "text",
          config: {
            edit: false
          }
        },
        {
          code: "recordDate",
          name: "最早记录时间",
          span: 6,
          type: "date",
          config: {}
        },
        {
          code: "recordTime",
          name: "最早记录时间",
          span: 6,
          type: "date",
          config: {}
        }
      ],
      // 增加/修改/详情 表单
      formItems: [
        {
          rowIndex: 1,
          items: [
            {
              code: "userCode",
              span: 6,
              name: "用户编码",
              type: "popup",
              config: {
                url: "base/user/user/user",
                filedList: [
                  { code: 'code', name: '编码' },
                  { code: 'name', name: '名称' }
                ],
                searcher: {},
                defaultValue: "",
                minLength: 0,
                maxLength: 20,
                disabled: false,
                require: true
              },
              handleEvent: {
                /**
                 * 开窗组件被选择
                 * @param code
                 * @param row
                 */
                onPopupClick: (code, row) => {
                  const formData = {
                    userName: row.name,
                    userCode: row.code,
                    userId: row.id
                  }
                  this.$refs.commonPage.updateFormData(formData)
                }
              }
            },
            {
              code: "userName",
              name: "用户名称",
              span: 6,
              type: "text",
              config: {
                edit: false
              }
            },
            {
              code: "drugCode",
              span: 6,
              name: "药品编码",
              type: "popup",
              config: {
                url: "health/content/content/recipe",
                filedList: [
                  { code: 'id', name: 'ID' },
                  { code: 'code', name: '编码' },
                  { code: 'name', name: '名称' }
                ],
                searcher: {},
                defaultValue: "",
                minLength: 0,
                maxLength: 20,
                disabled: false,
                require: true
              },
              handleEvent: {
                /**
                 * 开窗组件被选择
                 * @param code
                 * @param row
                 */
                onPopupClick: (code, row) => {
                  const formData = {
                    drugName: row.name,
                    drugCode: row.code,
                    drugId: row.id
                  }
                  this.$refs.commonPage.updateFormData(formData)
                }
              }
            },
            {
              code: "drugName",
              name: "药品名称",
              span: 6,
              type: "text",
              config: {
                edit: false
              }
            },
            {
              code: "recordDate",
              name: "最早记录时间",
              span: 6,
              type: "date",
              config: {}
            },
            {
              code: "recordTime",
              name: "最早记录时间",
              span: 6,
              type: "date",
              config: {}
            }
          ]
        }
      ]
    }
  }
}
</script>
